﻿<%@ Page Title="Item Requests" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" MaintainScrollPositionOnPostback ="true" CodeBehind="Requests.aspx.cs" Inherits="KorleBu.Requisitions" %>

<%@ Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="style.css" rel="Stylesheet" type="text/css" />    
    <style type="text/css">
        .style1
        {
        }
        .style2
        {
            width: 196px;
        }
        .style3
        {
            width: 149px;
        }
                .cssPager td
        {
            padding-left: 4px;      
            padding-right: 4px;
            text-decoration: underline;    
        }
        .style6
        {
            width: 92px;
            height: 36px;
        }
        .style7
        {
            width: 149px;
            height: 36px;
        }
        .style8
        {
            width: 92px;
            height: 32px;
        }
        .style9
        {
            width: 149px;
            height: 32px;
        }
        .style11
        {
            width: 85px;
        }
        .style12
        {
            width: 92px;
        }
        .style13
        {
        }
    </style>
    <script type="text/javascript">
        function CEO_NewWindow() {
            var ceo = window.open('RequestReport.aspx', '_blank', 'width=760,height=900,resizable=1,scrollbars=1');
            ceo.focus();
        }
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="sidebarcontentplaceholder" runat="server">
    <p>
        <br />
        <asp:Label ID="lblLoggedInUser" runat="server" Font-Bold="true" Visible="true"/>
    </p>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="maincontentplaceholder" runat="server">
    <asp:ScriptManager ID="ScriptManager" runat="server" />
    <asp:UpdatePanel ID="UpdatePanel" runat="server">
        <ContentTemplate>
            <div id="ebar">
                <asp:Label runat="server" ID="lblMasterError" CssClass="errorLabel" />
            </div>
            <asp:TabContainer ID="TabContainer" runat="server" AutoPostBack="true" 
                ActiveTabIndex="0" Width="700px">
                <asp:TabPanel ID="ViewRequests" runat="server" HeaderText="View Requests">
                    <HeaderTemplate>View Request</HeaderTemplate>
                    <ContentTemplate>
                            <asp:MultiView ID="mvViewRequests" runat="server" ActiveViewIndex="0">
                                <asp:View ID="vViewRequest"  runat="server">
                                    <asp:Label ID="lblNoRequest" runat="server" ForeColor="Red"></asp:Label>
                                    <br />
                                    <asp:GridView ID="gvViewRequests" runat="server" AutoGenerateColumns="False" 
                                        onrowcommand="gvViewRequests_RowCommand">
                                        <Columns>
                                            <asp:BoundField DataField="SatelliteStoreRequestID" HeaderText="No." />
                                            <asp:BoundField DataField="RequestDescription" HeaderText="Description" />
                                            <asp:BoundField DataField="RequestDate" HeaderText="Date Created" />
                                            <asp:TemplateField HeaderText="Status">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblStatusName" Text='<%# Bind("StatusName") %>' runat="server" />
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:ButtonField ButtonType="Button" CommandName="Select" Text="Select" />
                                        </Columns>
                                    </asp:GridView>
                                </asp:View>
                                <asp:View ID="vViewRequestItems" runat="server">
                                    <table style="width:100%;">
                                        <tr>
                                            <td class="style13">
                                                <strong>Request ID:</strong>
                                                <asp:Label ID="lblViewRequestID" runat="server"></asp:Label>
                                            </td>
                                            <td>
                                                <strong>Request Date:</strong>
                                                <asp:Label ID="lblViewDate" runat="server"></asp:Label>
                                            </td>
                                            <td>
                                                &nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td class="style13" colspan="3">
                                                <strong>Request Description:</strong>
                                                <asp:Label ID="lblViewDescription" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                    </table>
                                    <br />
                                    <asp:Button ID="btnSelectNewRequest" runat="server" 
                                        onclick="btnSelectNewRequest_Click" Text="Select new request" />
                                    <br />
                                    <br />
                                    <asp:GridView ID="gvViewRequestItems" runat="server" 
                                        AutoGenerateColumns="False" >
                                        <Columns>
                                            <asp:BoundField DataField="SatelliteStoreRequestID" HeaderText="ID" Visible="False" />
                                            <asp:BoundField DataField="ItemID" HeaderText="No." />
                                            <asp:BoundField DataField="ItemName" HeaderText="Name" />
                                            <asp:TemplateField HeaderText="Status">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblStatusName" Text='<%# Bind("StatusName") %>' runat="server" />
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="QtyRequested" HeaderText="Requested" />
                                            <asp:BoundField DataField="Allocated" HeaderText="Amount Approved" />
                                            <asp:BoundField DataField="Received" HeaderText="Amount Received" ReadOnly="True" SortExpression="Received" />
                                        </Columns>
                                    </asp:GridView>
                                    <br /><br />
                                    <input type="button" onclick="CEO_NewWindow();"
                                        value="Generate Request Report" runat="server"
                                        id="btnCEOReceipt" />
                                </asp:View>
                            </asp:MultiView>
                            <br />
                    </ContentTemplate>
                </asp:TabPanel>
                <asp:TabPanel runat="server" HeaderText="TabPanel1" ID="TablPanel1" ScrollBars="Auto"
                    BackColor="Transparent" ForeColor="#6EA459">
                    <HeaderTemplate>Create Request</HeaderTemplate>
                    <ContentTemplate>
                        <asp:MultiView ID="mvRequest" runat="server" ActiveViewIndex="0" >
                            <asp:View ID="vCreateRequest" runat="server">
                                <asp:Button ID="btnCreateRequest" runat="server" Text="Create Request" 
                                    onclick="btnCreateRequest_Click" ValidationGroup="Create" />
                            </asp:View>
                            <asp:View ID="vAddItemRequest" runat="server">
                                <br />
                            <fieldset style="width:100%;">
                           
                                <table ID="CreateRequest" style="width:100%;">
                                    <tr>
                                        <td style="vertical-align:top;">
                                            <table>
                                                <tr>
                                                    <th><asp:Label ID="lblItemCategory" runat="server" Text="Item Category:" CssClass="labels"></asp:Label></th>
                                                    <td><asp:DropDownList ID="ddlItemCategory" runat="server" AutoPostBack="True"></asp:DropDownList></td>
                                                </tr>
                                                <tr>
                                                    <td></td>
                                                    <td><asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" Text="Search by Category" /></td>
                                                </tr>
                                                <tr>
                                                    <th colspan="2" align="center"><asp:Label ID="lblOr" runat="server" Text="OR" CssClass="labels"></asp:Label></th>
                                                </tr>
                                                <tr>
                                                    <th> <asp:Label ID="lblItemName" runat="server" Text="Item Name:" CssClass="labels"></asp:Label></th>
                                                    <td><asp:TextBox ID="txtItemName" runat="server" MaxLength="99"></asp:TextBox></td>
                                                </tr>
                                                <tr>
                                                    <td></td>
                                                    <td><asp:Button ID="btnSearchItemName" runat="server" OnClick="btnSearchItemName_Click" Text="Search for Item"/></td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2"><asp:Label ID="lblMyError" runat="server" Font-Bold="True" ForeColor="Red"></asp:Label></td>
                                                </tr>
                                            </table>
                                        </td>
                                       <td>
                                            <asp:GridView ID="gvItemSearch" runat="server" AutoGenerateColumns="False" 
                                                AllowPaging="True" onpageindexchanging="gvItemSearch_PageIndexChanging" 
                                                PageSize="5" Width="50%" onrowcommand="gvItemSearch_RowCommand"
                                                AllowSorting="True" OnSorting="gvItemSearch_Sorting">
                                                <RowStyle HorizontalAlign="Right" VerticalAlign="Middle" />
                                                <Columns>
                                                    <asp:BoundField DataField="itemName" HeaderText="Name" SortExpression="itemName"/>
                                                    <asp:TemplateField HeaderText="Item Cost<br />GH¢">
                                                        <ItemTemplate>
                                                            <asp:Label runat="server" Visible="false" ID="lblItemID" Text='<%# Eval("itemID") %>'></asp:Label>
                                                            <asp:Label Text='<%# Eval("markupCost", "{0:0.00}") %>' runat="server" />
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField ConvertEmptyStringToNull="False" HeaderText="Qty.">
                                                        <EditItemTemplate>
                                                            <asp:DynamicControl ID="DynamicControl1" runat="server" DataField="" 
                                                                Mode="Edit" />
                                                        </EditItemTemplate>
                                                        <ItemTemplate>
                                                            <asp:TextBox ID="txtQuantity" runat="server" Height="25px" Width="36px" MaxLength="5"></asp:TextBox>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:ButtonField ButtonType="Button" CommandName="Add" Text="Add" />
                                                </Columns>
                                                <PagerTemplate> 
                                                    <table style="width: 265px"> 
                                                        <tr> 
                                                            <td> 
                                                                <asp:LinkButton ID="lnkFirstPage" CommandName="Page" CommandArgument="First" runat="server">[First]</asp:LinkButton> 
                                                            </td> 
                                                            <td class="style11"> 
                                                                <asp:LinkButton ID="lnkPrevPage" CommandName="Page" CommandArgument="Prev" runat="server">[Previous]</asp:LinkButton> 
                                                            </td> 
                                                            <td> 
                                                                <asp:LinkButton ID="lnkNextPage" CommandName="Page" CommandArgument="Next" runat="server" >[Next]</asp:LinkButton> 
                                                            </td> 
                                                            <td> 
                                                                <asp:LinkButton ID="lnkLastPage" CommandName="Page" CommandArgument="Last" runat="server">[Last]</asp:LinkButton> 
                                                            </td> 
                                                        </tr> 
                                                    </table> 
                                                </PagerTemplate> 

                                            </asp:GridView>
                                        </td>
                                    </tr>
                                </table>
                                </fieldset>
                                <fieldset style="width: 100%;">
                                <table id="CreateRequest2" style="width:100%;">
                                    <tr>
                                        <td>
                                            <strong>Request ID:</strong>
                                            <asp:Label ID="lblRequestID" runat="server"></asp:Label>
                                        </td>
                                        <td>
                                            <strong>Request Created:</strong>
                                            <asp:Label ID="lblRequestDate" runat="server"></asp:Label>
                                        </td>
                                        <td>
                                            &nbsp;</td>
                                    </tr>
                                    <!--<tr>
                                        <td colspan="3">
                                            Description:
                                            <asp:Label ID="lblDescription" runat="server" ForeColor="Red"></asp:Label>
                                        </td>
                                    </tr>-->
                                    <tr>
                                        <td align="right">
                                            <strong><asp:Label ID="lblEnteredDescription" runat="server" CssClass="labels" 
                                                Text="Request Description:" Font-Bold="True"></asp:Label></strong>
                                        </td>
                                        <td>
                                            <asp:DropDownList ID="ddlDescription" runat="server" Width="488px" AutoPostBack="True" OnSelectedIndexChanged="ddlDescription_SelectedIndexChanged" ></asp:DropDownList>
                                            <asp:Label ID="lblAstrisk" runat="server" ForeColor="Red" Visible="False" Text="*"></asp:Label>
                                            
                                        </td>
                                    </tr>
                                    <tr>
                                        <th align="right"><asp:Label ID="lblOtherSpecified" runat="server" Text="New Description:" CssClass="labels" Visible="False"></asp:Label></th>
                                        <td><asp:TextBox ID="txtOtherSpecified" runat="server" Width="488px" MaxLength="99" Visible="False"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                        <td align="center" colspan="3">
                                            <asp:Label ID="lblDescriptionError" runat="server" ForeColor="Red"></asp:Label>
                                            <br />
                                            <asp:Label ID="lblRequestMissing" runat="server" ForeColor="Red"></asp:Label>
                                        </td>
                                    </tr>
                                </table>
                                <br />
                                <asp:GridView ID="gvRequest" runat="server" AutoGenerateColumns="False" 
                                        onrowcancelingedit="gvRequest_RowCancelingEdit" 
                                        onrowcommand="gvRequest_RowCommand"
                                        onrowediting="gvRequest_RowEditing" onrowupdating="gvRequest_RowUpdating">
                                    <RowStyle HorizontalAlign="Right" VerticalAlign="Middle" />
                                    <Columns>
                                        <asp:TemplateField HeaderText="Item Name">
                                            <ItemTemplate>
                                                <asp:Label runat="server" ID="lblItemName" Text='<%# Eval("ItemName") %>'></asp:Label>
                                                <asp:Label runat="server" ID="lblItemID" Text='<%# Eval("ItemID") %>' Visible="false"></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Quantity">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="txtEditRequestQty" runat="server" Height="25px" MaxLength="5" 
                                                    Text='<%# Bind("QtyRequested") %>' Width="65px"></asp:TextBox>
                                                <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Enter a number greater than 0" 
                                                    ControlToValidate="txtEditRequestQty" Type="Integer" MinimumValue="1" 
                                                    MaximumValue="999999" Display="Dynamic" SetFocusOnError="true" ForeColor="Red"
                                                    ValidationGroup="edit"></asp:RangeValidator>
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                                    ControlToValidate="txtEditRequestQty" Display="Dynamic" ErrorMessage="Required" 
                                                    ForeColor="Red" SetFocusOnError="True" ValidationGroup="edit"></asp:RequiredFieldValidator>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="lblQtyRequested" runat="server" Text='<%# Bind("QtyRequested") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Item Cost<br />GH¢">
                                            <ItemTemplate>
                                                <asp:Label ID="Label2" Text='<%# Eval("markupCost", "{0:0.00}") %>' runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Total Cost<br />GH¢">
                                            <ItemTemplate>
                                                <asp:Label ID="Label3" Text='<%# CalcCost(Eval("markupCost"), Eval("QtyRequested")) %>' runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:CommandField ButtonType="Button" ShowEditButton="True" 
                                            ValidationGroup="edit" />
                                        <asp:ButtonField ButtonType="Button" CommandName="Remove" Text="Delete" />
                                    </Columns>
                                </asp:GridView>
                                <br />
                                <asp:Button ID="btnSubmitRequest" runat="server" Text="Submit Request" 
                                        onclick="btnSubmitRequest_Click" />
                                    &nbsp;
                                    <asp:Button ID="btnCancelRequest" runat="server" Text="Cancel" 
                                        onclick="btnCancelRequest_Click" />
                                </fieldset>
                            </asp:View>
                        </asp:MultiView>
                        
                    </ContentTemplate>
                </asp:TabPanel>
                
            </asp:TabContainer>
        </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>
